public class MyInteger {
    public static String toString(int value, int radix) {
        if(radix == 10){
            return value+" ";
        }
        if(radix == 2 || radix == 4 || radix == 8 || radix == 16){
            int mask,n = 0;
            for(mask = radix - 1; mask > 0; mask>>>=1)
                n++;
            mask = radix - 1;
            char butter[] = new char[(int)(32.0/n+0.5)];
            for (int i = butter.length - 1; i >= 0; i--) {
                int bit = value&mask;
                butter[i] = (char) (bit<=9?bit+'0':bit+'a'-10);
                value>>>=n;
            }
            if (radix == 2 || radix == 4){
                return new String(butter);
            }
            if(radix == 8){
                return "0"+new String(butter);
            }
            return "0x"+new String(butter);
        }
        throw new IllegalArgumentException("radix参数值"+radix+"表示的禁止无效");
    }
}
